In [2]:
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib import gridspec
import os
import numpy as np
import csv
import pandas as pd
import matplotlib.colors as colors
from IPython.display import Markdown, display
import matplotlib
import collections
import folium
from textwrap import wrap
import branca
from collections import defaultdict
from folium.plugins import HeatMap, HeatMapWithTime
import seaborn as sns
import ast

# import fancy_plot as fp
%matplotlib inline

Helper Functions

In [3]:
def calc_parcels_kpis(folder):

    KPI_fn = "Parcels.csv"
    path = os.path.join(base_path, folder)
    delivered = 0
    with open(os.path.join(path, KPI_fn), 'r') as f:
        parcels = list(csv.reader(f, delimiter=','))
        #print(parcels[0])
        parcels = parcels[1:] #drop the length of array

    time_request, time_picked_up, time_delivered, travel_time_optim, vehicle_pickup = [],[],[],[],[]
    for time in parcels:
        try:
            time_delivered.append(float(time[6]))
            time_request.append(float(time[4]))
            time_picked_up.append(float(time[5]))
            travel_time_optim.append(float(time[7]))
            vehicle_pickup.append(float(time[8]))
            delivered = delivered+1
        except:
            # if parcel is not delivered yet
#             print("sKIPPING BECAUSE OF PROBLEM")
            break


    delivery_time = np.array(time_delivered) - np.array(time_request)
    delay = delivery_time - np.array(travel_time_optim)
    TimeOnVehicle = np.array(time_delivered) - np.array(time_picked_up)
    WaitingToPickUp = np.array(time_picked_up) - np.array(time_request)
    return delivery_time, delay, TimeOnVehicle, WaitingToPickUp, delivered

#returned as list
def calc_parcels_kpis_Mean(folder):
    delivery_time, delay, TimeOnVehicle, WaitingToPickUp, delivered = calc_parcels_kpis(folder)
    return (np.mean(delivery_time), np.mean(delay), np.mean(TimeOnVehicle), np.mean(WaitingToPickUp))


def calc_driven_distance_flex(folder, steps, n_vehicles):
    # returns m
    dirpath = os.path.join(base_path,folder + "/vehicles")
    time_list = np.linspace(time_first, time_last, int((time_last-time_first)/steps+1))[:-2]
#     if steps == 140:
#         filename = 'vehicles-47180.txt'
#     else:
    filename = 'vehicles-{}.txt'.format(int((time_list[-1:])[0]))
    veh_current = []
    
    with open(os.path.join(dirpath, filename), 'r') as txt:
        all_txt = txt.read()
        lines = all_txt.split("#")     
        lines.remove(lines[0])
        lines = lines[0].split("\n")
        lines.remove(lines[0])

        for i in lines[:n_vehicles]:
            veh = []
            new = i.split("%")
            if new == ['']:
                break
            else:
                status = new[0].split(" ")
                executed = new[1].split(" ")
                planned = new[2].split(" ")
                occ = new[5]
                distance = new[6]
                while '' in executed: executed.remove('')  
                while '' in status: status.remove('')  
                while '' in planned: planned.remove('')  
                veh.append(executed)
                veh.append(status)
                veh.append(planned)
                veh.append(int(occ))
                veh.append(int(distance))
                veh_current.append(veh)

    tt = 0
    for veh in veh_current:
        dist = veh[4]
        tt += dist
    return tt / 1000 # returns km

# reurns the mean of mean loaded parcels of a run
def mean_parcel(folder, used_vehicles):
    occ_fn = "occuoancy_adv.csv"
    with open(os.path.join(os.path.join(base_path,folder), occ_fn), 'r') as f:
        occ = list(csv.reader(f, delimiter=','))
        occ = occ[1:] #drop the length of array
    occ_rebal, occ_idle, occ_pick = [],[], []
    occ_1, occ_2, occ_3, occ_4, occ_5 = [],[],[],[],[]
    occ_6, occ_7, occ_8, occ_9, occ_10, occ_11 = [],[],[],[],[],[]
    for time in occ:
        i = time[1:]
        occ_rebal.append(i.count("-3"))
        occ_idle.append(i.count("-2"))
        occ_pick.append(i.count("-1"))
        occ_1.append(i.count("1"))
        occ_2.append(i.count("2"))
        occ_3.append(i.count("3"))
        occ_4.append(i.count("4"))
        occ_5.append(i.count("5"))
        occ_6.append(i.count("6"))
        occ_7.append(i.count("7"))
        occ_8.append(i.count("8"))
        occ_9.append(i.count("9"))
        occ_10.append(i.count("10"))
        occ_11.append(i.count("11"))
    
    mean_parcels = []

    for i, idle in enumerate(occ_idle):
        sum_loaded = occ_1[i] + 2*occ_2[i] + 3*occ_3[i] +  4*occ_4[i] + 5*occ_5[i] + 6*occ_6[i] + 7*occ_7[i]
        #print(sum_loaded)
        mean_parcel_now = sum_loaded/used_vehicles
        mean_parcels.append(mean_parcel_now)
    return np.mean(mean_parcels)


def read_kpi_ignored(folder):
    KPI_fn = "KPIs.csv"
    with open(os.path.join(base_path, folder, KPI_fn), 'r') as f:
        kpi = list(csv.reader(f, delimiter=','))
        #print(kpi[0])
        kpi = kpi #drop the length of array
        
    pickups, drops, ignored, open_order, rebalancing = [],[],[],[],[]
    for time in kpi:
        ignored.append(int(time[4])/considered_depots) # is calculated based on requests

    return ignored

def rolling_sum(list):
    out = []
    sum= 0
    for i in list:
        sum += i
        out.append(sum)
    return out
    

def service_rate(folder, total_demand):
    ignored = read_kpi_ignored(folder)
    total_ignored = rolling_sum(ignored)
    return (100-total_ignored[-1:][0]/total_demand*100)

def cost_computer(folder, total_demand, cost_weight, ignore_cost, n_vehicles):
    _,delay,_,_,_ = calc_parcels_kpis(folder)
    delay = np.sum(delay)
    
    ignored = read_kpi_ignored(folder)
    total_ignored = rolling_sum(ignored)
    
    sum_dist = calc_driven_distance_flex(folder, 100, n_vehicles)
    
    cost_total_end = (1-cost_weight)* np.sum(delay) + \
                 cost_weight*sum_dist + \
                 total_ignored[-1:][0] * ignore_cost
    
    return cost_total_end

def diff_x(x):
    a = []
    for i in range(len(x)):
        if i == 0:
            pass
        else:
            a.append(x[i] - x[0])

    return [0, *a]


def mean_computer(x_list):
    return np.mean(x_list, axis=1)

def printmd(string):
    display(Markdown(string))

Graph Functions

In [4]:
def load_demand(data_path, input_folder):
    with open(os.path.join(data_path,input_folder,'demand','Demand_basic.csv'), 'r') as f:
        demand = list(csv.reader(f, delimiter=','))
        #print(occ)
        demand = demand[1:] #drop the length of array
        demand_time = []
        demand_long = []
        demand_lat = []
        demand_station = []
        for i in demand:
            demand_time.append(int(i[0].split(" ")[0]))
            demand_long.append(float(i[0].split(" ")[1]))
            demand_lat.append(float(i[0].split(" ")[2]))
            demand_station.append(float(i[0].split(" ")[3]))

    demand_time = np.array(demand_time)
    demand_time = demand_time[(demand_time > time_first) & (demand_time < max_hour)]
    
    return demand, demand_time

def load_graph_kpis(folder_costs, demand_time):
    total_demand = len(demand_time)

    delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost = [],[],[],[],[],[]
    for folder in folder_costs:
        delivery_time_stores.append(calc_parcels_kpis_Mean(folder)[0])
        delay_stores.append(calc_parcels_kpis_Mean(folder)[1])
        TimeOnVehicle_stores.append(calc_parcels_kpis_Mean(folder)[2])
        WaitingToPickUp_stores.append(calc_parcels_kpis_Mean(folder)[3])
        delivered.append(calc_parcels_kpis(folder)[4])
        overall_cost.append(cost_computer(folder, total_demand, 0.5, 10000, used_vehicles))
        
        
    total_demand = len(demand_time)
    
    service_rate_stores = []
    for folder in folder_costs:
        service_rate_stores.append(service_rate(folder, total_demand))
        
    driven_distance_stores = []
    for i, folder in enumerate(folder_costs):
        driven_distance_stores.append(calc_driven_distance_flex(folder, steps, used_vehicles))

    mean_parcels_stores = []
    for folder in folder_costs:
        mean_parcels_stores.append(mean_parcel(folder, used_vehicles))
    
    return delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores

def load_graph_index(delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores):
    dif_overall = diff_x(overall_cost)
    dif_delivery = diff_x(delivery_time_stores)
    dif_delay = diff_x(delay_stores)
    dif_veh = diff_x(TimeOnVehicle_stores)
    dif_wait = diff_x(WaitingToPickUp_stores)
    dif_service = diff_x(service_rate_stores)
    dif_dist = diff_x(driven_distance_stores)
    dif_parcels = diff_x(mean_parcels_stores)
    dif_delivery_perorder = diff_x(np.divide(driven_distance_stores,delivered))

    return dif_overall, dif_delivery, dif_delay, dif_veh, dif_wait, dif_service, dif_dist, dif_parcels, dif_delivery_perorder

def bar_computer(folder_costs, label_costs, image_num, delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores, dif_overall, dif_delivery, dif_delay, dif_veh, dif_wait, dif_service, dif_dist, dif_parcels, dif_delivery_perorder, color_map):

    bar_width = 1/(len(folder_costs)+1)
#     color_map = cm.get_cmap("viridis", len(folder_costs) - 1)
#     color_map = mcolors.LinearSegmentedColormap.from_list('my_colormap', [*cm.viridis.colors[::25], [1,0,0]])


#     plt.figure(i)
    plt.subplots(figsize=(25,14))

    gs = gridspec.GridSpec(2, 5, width_ratios=[1, 1, 5, 1, 1]) 
    gs.update(wspace = 0.5)

    plt.subplot(gs[0,0])
    X = np.arange(1)
    for i in range(len(folder_costs)):
        plt.bar(X + i*bar_width, overall_cost[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Overall Cost", ))
    plt.ylim(0,max(overall_cost)*1.1)
    plt.ylabel("Cost [s]")

    plt.subplot(gs[0,1])
    X = np.arange(1)
    for i in range(len(folder_costs)):
        plt.bar(X + i*bar_width, service_rate_stores[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Service rate", ))
    plt.ylim(0,max(service_rate_stores)*1.1)
    plt.ylabel("Percentage [\%]")
    
    plt.subplot(gs[0,2])
    X = np.arange(4)
    for i in range(len(folder_costs)):
        plt.bar(X + (i*bar_width), (delivery_time_stores[i], delay_stores[i], TimeOnVehicle_stores[i], WaitingToPickUp_stores[i]),\
                color=color_map(i), width=bar_width, label=label_costs[i])
    plt.xticks(X + i*bar_width/2, ("Delivery time", "Delay", "Time on \n vehicle", "Waiting time"))
#     plt.legend(loc='upper right')
    plt.ylim(0,max(*delivery_time_stores,*delay_stores,*TimeOnVehicle_stores,*WaitingToPickUp_stores)*1.1)
    plt.ylabel("Time [s]")
    
    plt.subplot(gs[0,3])
    X = np.arange(1)
    for i in range(len(folder_costs)):
        plt.bar(X + i*bar_width, mean_parcels_stores[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Mean loaded parcels", ))
    plt.ylim(0,max(mean_parcels_stores)*1.1)
    plt.ylabel("Counts")  
    
    plt.subplot(gs[0,4])
    X = np.arange(1)
    for i in range(len(folder_costs)):
        plt.bar(X + (i*bar_width),  driven_distance_stores[i] , color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Total driven distance",))
    plt.ylim(0,max(driven_distance_stores)*1.1)
    plt.ylabel("Distance [km]")


#     label_costs = label_costs[1:]
#     color_map = cm.get_cmap("viridis", len(folder_costs))


    plt.subplot(gs[1,0])
    X = np.arange(1)
    for i in range(len(dif_delivery)):
        plt.bar(X + i*bar_width, dif_overall[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Overall Costs", ))
    #plt.legend()
    plt.ylabel("Change in cost [\%]")
#     plt.ylim(min(dif_overall)*1.1,max(dif_overall)*1.1)


    plt.subplot(gs[1,1])
    X = np.arange(1)
    for i in range(len(dif_delivery)):
        plt.bar(X + i*bar_width, dif_service[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Service rate", ))
    #plt.legend()
    plt.ylabel("Change in percentage [\%]")
#     plt.ylim(min(dif_service)*1.1,max(dif_service)*1.1)


    plt.subplot(gs[1,2])
    X = np.arange(4)
    for i in range(len(dif_delay)):
        plt.bar(X + (i*bar_width), (dif_delivery[i], dif_delay[i], dif_veh[i], dif_wait[i]),
                color=color_map(i), width=bar_width, label=label_costs[i])
    plt.xticks(X + i*bar_width/2, ("Delivery time", "Delay", "Time on \n vehicle", "Waiting time"))
    plt.ylim(min(*dif_delivery,*dif_delay,*dif_veh,*dif_wait)*1.1,max(*dif_delivery,*dif_delay,*dif_veh,*dif_wait)*1.5)
    plt.ylabel("Change in time KPIs [s]")
    plt.legend(label_costs, loc="lower center", bbox_to_anchor=(0.5, -0.7), fancybox=True, shadow=False, ncol=2)


    plt.subplot(gs[1,3])
    X = np.arange(1)
    for i in range(len(dif_delay)):
        plt.bar(X + i*bar_width, dif_parcels[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Mean loaded parcels", ))
#     plt.ylim(min(dif_parcels)*1.1,max(dif_parcels)*1.1)
    plt.ylabel("Change in loaded parcels")

    plt.subplot(gs[1,4])
    X = np.arange(1)
    for i in range(len(dif_delay)):
        plt.bar(X + i*bar_width, dif_dist[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Total driven distance", ))
#     plt.ylim(min(dif_dist)*1.1,max(dif_dist)*1.1)
    plt.ylabel("Change in distance [km]")
    
    #     plt.savefig(os.path.join(base_path,'output_images','result_'+str(input_folder)+'.png'))
    plt.show()
    
def bar_box_computer(folder_costs, label_costs, image_num, delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores, dif_overall, dif_delivery, dif_delay, dif_veh, dif_wait, dif_service, dif_dist, dif_parcels, color_map):
    
    bar_width = 1/(len(folder_costs)+1)
#     color_map = cm.get_cmap("viridis", len(folder_costs) - 1)
#     color_map = mcolors.LinearSegmentedColormap.from_list('my_colormap', [*cm.viridis.colors[::25], [1,0,0]])


#     plt.figure(i)
    plt.subplots(figsize=(25,14))

    gs = gridspec.GridSpec(3, 5, width_ratios=[1, 1, 5, 1, 1], height_ratios=[1,1,1]) 
    gs.update(wspace = 0.5, hspace = 0.4)

    plt.subplot(gs[0,0])
    X = np.arange(1)
    for i in range(len(folder_costs)):
        plt.bar(X + i*bar_width, mean_computer(overall_cost)[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Overall Cost", ))
    plt.ylim(0,max(mean_computer(overall_cost))*1.1)
    plt.ylabel("Cost [s]")

    plt.subplot(gs[0,1])
    X = np.arange(1)
    for i in range(len(folder_costs)):
        plt.bar(X + i*bar_width, mean_computer(service_rate_stores)[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Service rate", ))
    plt.ylim(0,max(mean_computer(service_rate_stores))*1.1)
    plt.ylabel("Percentage [\%]")
    
    plt.subplot(gs[0,2])
    X = np.arange(4)
    for i in range(len(folder_costs)):
        plt.bar(X + (i*bar_width), (mean_computer(delivery_time_stores)[i], mean_computer(delay_stores)[i], mean_computer(TimeOnVehicle_stores)[i], mean_computer(WaitingToPickUp_stores)[i]),\
                color=color_map(i), width=bar_width, label=label_costs[i])
    plt.xticks(X + i*bar_width/2, ("Delivery time", "Delay", "Time on \n vehicle", "Waiting time"))
#     plt.legend(loc='upper right')
    plt.ylim(0,max(*mean_computer(delivery_time_stores),*mean_computer(delay_stores),*mean_computer(TimeOnVehicle_stores),*mean_computer(WaitingToPickUp_stores))*1.1)
    plt.ylabel("Time [s]")
    
    plt.subplot(gs[0,3])
    X = np.arange(1)
    for i in range(len(folder_costs)):
        plt.bar(X + i*bar_width, mean_computer(mean_parcels_stores)[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Mean loaded parcels", ))
    plt.ylim(0,max(mean_computer(mean_parcels_stores))*1.1)
    plt.ylabel("Counts")  
    
    plt.subplot(gs[0,4])
    X = np.arange(1)
    for i in range(len(folder_costs)):
        plt.bar(X + (i*bar_width),  mean_computer(driven_distance_stores)[i] , color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Total driven distance",))
    plt.ylim(0,max(mean_computer(driven_distance_stores))*1.1)
    plt.ylabel("Distance [km]")


#     label_costs = label_costs[1:]
#     color_map = cm.get_cmap("viridis", len(folder_costs))


    plt.subplot(gs[1,0])
    X = np.arange(1)
    for i in range(len(dif_delivery)):
        plt.bar(X + i*bar_width, mean_computer(dif_overall)[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Overall Costs", ))
    #plt.legend()
    plt.ylabel("Change in cost [\%]")
#     plt.ylim(min(dif_overall)*1.1,max(dif_overall)*1.1)


    plt.subplot(gs[1,1])
    X = np.arange(1)
    for i in range(len(dif_delivery)):
        plt.bar(X + i*bar_width, mean_computer(dif_service)[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Service rate", ))
    #plt.legend()
    plt.ylabel("Change in percentage [\%]")
#     plt.ylim(min(dif_service)*1.1,max(dif_service)*1.1)


    plt.subplot(gs[1,2])
    X = np.arange(4)
    for i in range(len(dif_delay)):
        plt.bar(X + (i*bar_width), (mean_computer(dif_delivery)[i], mean_computer(dif_delay)[i], mean_computer(dif_veh)[i], mean_computer(dif_wait)[i]),
                color=color_map(i), width=bar_width, label=label_costs[i])
    plt.xticks(X + i*bar_width/2, ("Delivery time", "Delay", "Time on \n vehicle", "Waiting time"))
    plt.ylim(min(*mean_computer(dif_delivery),*mean_computer(dif_delay),*mean_computer(dif_veh),*mean_computer(dif_wait))*1.1,max(*mean_computer(dif_delivery),*mean_computer(dif_delay),*mean_computer(dif_veh),*mean_computer(dif_wait))*1.5)
    plt.ylabel("Change in time KPIs [s]")
    plt.legend(label_costs, loc="lower center", bbox_to_anchor=(0.5, -2.25), fancybox=True, shadow=False, ncol=4)


    plt.subplot(gs[1,3])
    X = np.arange(1)
    for i in range(len(dif_delay)):
        plt.bar(X + i*bar_width, mean_computer(dif_parcels)[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Mean loaded parcels", ))
#     plt.ylim(min(dif_parcels)*1.1,max(dif_parcels)*1.1)
    plt.ylabel("Change in loaded parcels")

    plt.subplot(gs[1,4])
    X = np.arange(1)
    for i in range(len(dif_delay)):
        plt.bar(X + i*bar_width, mean_computer(dif_dist)[i], color=color_map(i), width=bar_width)
    plt.xticks(X + i*bar_width/2, ("Total driven distance", ))
#     plt.ylim(min(dif_dist)*1.1,max(dif_dist)*1.1)
    plt.ylabel("Change in distance [km]")
    
    
    
    plt.subplot(gs[2,0])
    plt.boxplot(overall_cost)
    plt.xticks([2], ['Overall Cost'])
    plt.ylabel("Cost [s]")

    
    plt.subplot(gs[2,1])
    plt.boxplot(service_rate_stores)
    plt.xticks([2], ["Service Rate"])
    plt.ylabel("Percentage [\%]")


    plt.subplot(gs[2,2])
    plt.boxplot(delivery_time_box, positions=np.array(range(len(folder_costs))), sym='', widths=0.8)
    plt.boxplot(delay_box, positions=np.array(range(len(folder_costs)))*1+ 4, sym='', widths=0.8)
    plt.boxplot(TimeOnVehicle_box, positions=np.array(range(len(folder_costs)))*1+ 8, sym='', widths=0.8)
    plt.boxplot(WaitingToPickUp_box, positions=np.array(range(len(folder_costs)))*1 + 12, sym='', widths=0.8)
    ticks = ["Delivery time", "Delay", "Time on \n vehicle", "Waiting time"]
    plt.xticks([1,5,9,13], ticks)
    plt.xlim(-1, 16)
    plt.ylabel("Time [s]")

    
    plt.subplot(gs[2,3])
    plt.boxplot(mean_parcels_stores)
    plt.xticks([2], ["Mean Loaded Parcels"])
    plt.ylabel("Counts")  

        
    plt.subplot(gs[2,4])
    plt.boxplot(driven_distance_stores)
    plt.xticks([2], ["Total driven distance"])
    plt.ylabel("Distance [km]")

    #     plt.savefig(os.path.join(base_path,'output_images','result_'+str(input_folder)+'.png'))
    plt.show()

Loading Data

In [7]:
n_datasets = 5

result_logger = pd.read_csv('/home/stavya/Desktop/outputlog_new.csv', index_col=0)


# Sorting values by Method 
result_logger = result_logger.sort_values(by = ['data_folder', 'anticipation_flag'])[['output_folder', 'anticipation_flag' , 'data_folder', 'temporal_type', 'spatial_type', 'clusters']] 
result_logger = result_logger.reset_index(drop = 'True')


result_logger = result_logger[result_logger['anticipation_flag'] != 'RA routing'] 
result_logger = result_logger[result_logger['anticipation_flag'] != 'RA Candidate'] 
result_logger = result_logger[result_logger['anticipation_flag'] != 'Perfect Anticipation'] 


# Grouping by data set
result_logger_dict = dict(tuple(result_logger.groupby(['temporal_type', 'spatial_type', 'clusters'])))

output_folders = []
data_columns = []
input_folders = []

for key in result_logger_dict.keys():
    folder = []
    columns = []
    input_folder = []

    

    for j in range(n_datasets): #n_datasets
        n_type = len(result_logger_dict[key]['anticipation_flag'].unique())
        count = j*n_type
        folder.append(result_logger_dict[key][['output_folder']].iloc[count:count+n_type])
        columns.append(result_logger_dict[key][['anticipation_flag']].iloc[count:count+n_type])
        input_folder.append(result_logger_dict[key][['data_folder']].iloc[count])


    input_folders.append(input_folder)
    output_folders.append(folder)
    data_columns.append(columns)

Performance Comparison Overall

In [21]:
     
delivery_time_combined, delay_combined, TimeOnVehicle_combined, WaitingToPickUp_combined, delivered_combined, overall_cost_combined, mean_parcels_combined, driven_distance_combined, service_rate_combined = [],[],[],[],[],[],[],[],[]
        
dif_overall_combined, dif_delivery_combined, dif_delay_combined, dif_veh_combined, dif_wait_combined, dif_service_combined, dif_dist_combined, dif_parcels_combined, dif_delivery_perorder_combined = [],[],[],[],[],[],[],[],[]  
    
for num, key in enumerate(result_logger_dict.keys()):
    for i in range(n_datasets):
        folder_costs = []
        label_costs = []

        # Obtaining input folders
        for j,item in enumerate(output_folders[num][i].iterrows()):
            _, item = item
            folder_costs.append(item[0])
            label_costs.append(data_columns[num][i].iloc[j][0])
            
        # Computing metrics
        demand, demand_time = load_demand(data_path, input_folders[num][i][0])
        
        delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores = load_graph_kpis(folder_costs, demand_time)
        
        dif_overall, dif_delivery, dif_delay, dif_veh, dif_wait, dif_service, dif_dist, dif_parcels, dif_delivery_perorder = load_graph_index(delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores)
        
        #Combining metrics
        delivery_time_combined.append(delivery_time_stores)
        delay_combined.append(delay_stores) 
        TimeOnVehicle_combined.append(TimeOnVehicle_stores)
        WaitingToPickUp_combined.append(WaitingToPickUp_stores) 
        delivered_combined.append(delivered) 
        overall_cost_combined.append(overall_cost)
        mean_parcels_combined.append(mean_parcels_stores)
        driven_distance_combined.append(driven_distance_stores)
        service_rate_combined.append(service_rate_stores)
        
        dif_overall_combined.append(dif_overall)
        dif_delivery_combined.append(dif_delivery)
        dif_delay_combined.append(dif_delay)
        dif_veh_combined.append(dif_veh)
        dif_wait_combined.append(dif_wait)
        dif_service_combined.append(dif_service)
        dif_dist_combined.append(dif_dist)
        dif_parcels_combined.append(dif_parcels)
        
        
# Computing Mean And Standard Deviation of combined metrics
mean_delivery_time = np.mean(delivery_time_combined, axis=0)
mean_delay = np.mean(delay_combined, axis=0)
mean_TimeOnVehicle = np.mean(TimeOnVehicle_combined, axis=0)
mean_WaitingToPickUp = np.mean(WaitingToPickUp_combined, axis=0)
mean_delivered = np.mean(delivered_combined, axis=0)
mean_overall_cost = np.mean(overall_cost_combined, axis=0)
mean_mean_parcels = np.mean(mean_parcels_combined, axis=0)
mean_driven_distance = np.mean(driven_distance_combined, axis=0)
mean_service_rate = np.mean(service_rate_combined, axis=0)

mean_dif_overall = np.mean(dif_overall_combined, axis=0)
mean_dif_delivery = np.mean(dif_delivery_combined, axis=0)
mean_dif_delay = np.mean(dif_delay_combined, axis=0)
mean_dif_veh = np.mean(dif_veh_combined, axis=0)
mean_dif_wait = np.mean(dif_wait_combined, axis=0)
mean_dif_service = np.mean(dif_service_combined, axis=0)
mean_dif_dist = np.mean(dif_dist_combined, axis=0)
mean_dif_parcels = np.mean(dif_parcels_combined, axis=0)
mean_dif_delivery_perorder = []
    
# Plotting graphs
bar_computer(folder_costs, label_costs, 'Average', mean_delivery_time, mean_delay, mean_TimeOnVehicle, mean_WaitingToPickUp, mean_delivered, overall_cost, mean_mean_parcels, mean_driven_distance, mean_service_rate, mean_dif_overall, mean_dif_delivery, mean_dif_delay, mean_dif_veh, mean_dif_wait, mean_dif_service, mean_dif_dist, mean_dif_parcels, mean_dif_delivery_perorder, color_map)
In [38]:
df = pd.concat([
    pd.DataFrame(np.tile(np.array(['Myopic','Adjustment with Rewards','Adjustment with Penalth & Rewards']),80)),
    pd.DataFrame(np.reshape(np.array(overall_cost_combined),(240,-1))),
    pd.DataFrame(np.reshape(np.array(service_rate_combined),(240,-1))),
    pd.DataFrame(np.reshape(np.array(delivered_combined),(240,-1))),
    pd.DataFrame(np.reshape(np.array(delivery_time_combined),(240,-1))),
    pd.DataFrame(np.reshape(np.array(delay_combined),(240,-1))),
    pd.DataFrame(np.reshape(np.array(TimeOnVehicle_combined),(240,-1))),
    pd.DataFrame(np.reshape(np.array(WaitingToPickUp_combined),(240,-1))),
    pd.DataFrame(np.reshape(np.array(driven_distance_combined),(240,-1)))], axis=1)
df.columns = ['Simulation Type', 'Overall Cost','Service Rate','Orders Delivered','Delivery Time','Delay Time','Time On Vehicle','Waiting Time','Distance Travelled']
In [41]:
df.to_csv('/home/stavya/Desktop/All_Results.csv',index_label=False)

Service Rate Comparison across Data Type

In [8]:
plt.rcParams.update({'font.size': 16})
time_first= 9 *3600
max_hour = 12*3600
finishing_time = 15
time_last=max_hour+finishing_time*60
steps = 100
used_vehicles = 10
considered_depots = 5

data_path = "/home/stavya/Desktop/deliver_fastest/Data_Generation/data/amsterdam"
base_path = "/home/stavya/Desktop/deliver_fastest/output/amsterdam"
plt.subplots(figsize=(25,50))

gs = gridspec.GridSpec(4, 4, width_ratios=[1, 1, 1, 1]) 
gs.update(wspace = 0.5, hspace = 0.5)

color_map = colors.ListedColormap(['#fde725','#21918c','#3b528b','#440154'])


row = 0
column = 0
for num, key in enumerate(result_logger_dict):
         
    delivery_time_combined, delay_combined, TimeOnVehicle_combined, WaitingToPickUp_combined, delivered_combined, overall_cost_combined, mean_parcels_combined, driven_distance_combined, service_rate_combined = [],[],[],[],[],[],[],[],[]

    dif_overall_combined, dif_delivery_combined, dif_delay_combined, dif_veh_combined, dif_wait_combined, dif_service_combined, dif_dist_combined, dif_parcels_combined, dif_delivery_perorder_combined = [],[],[],[],[],[],[],[],[]  
        
    
    for i in range(n_datasets):
        folder_costs = []
        label_costs = []

        # Obtaining input foldersa
        for j,item in enumerate(output_folders[num][i].iterrows()):
            _, item = item
            folder_costs.append(item[0])
            label_costs.append(data_columns[num][i].iloc[j][0])
            
        demand, demand_time = load_demand(data_path, input_folders[num][i][0])

        delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores = load_graph_kpis(folder_costs, demand_time)

        dif_overall, dif_delivery, dif_delay, dif_veh, dif_wait, dif_service, dif_dist, dif_parcels, dif_delivery_perorder = load_graph_index(delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores)
        
        
         #Combining metrics
        delivery_time_combined.append(delivery_time_stores)
        delay_combined.append(delay_stores) 
        TimeOnVehicle_combined.append(TimeOnVehicle_stores)
        WaitingToPickUp_combined.append(WaitingToPickUp_stores) 
        delivered_combined.append(delivered) 
        overall_cost_combined.append(overall_cost)
        mean_parcels_combined.append(mean_parcels_stores)
        driven_distance_combined.append(driven_distance_stores)
        service_rate_combined.append(service_rate_stores)
        
        dif_overall_combined.append(dif_overall)
        dif_delivery_combined.append(dif_delivery)
        dif_delay_combined.append(dif_delay)
        dif_veh_combined.append(dif_veh)
        dif_wait_combined.append(dif_wait)
        dif_service_combined.append(dif_service)
        dif_dist_combined.append(dif_dist)
        dif_parcels_combined.append(dif_parcels)
    

    # Computing box plot metrics
    service_rate_box = [list(i) for i in zip(*service_rate_combined)]
        
    bar_width = 1/(len(folder_costs)+1)
    
    X = np.arange(1)
    plt.subplot(gs[row,column])
    
    
    for i in range(len(folder_costs)):
        plt.bar(X + i*bar_width, np.mean(dif_service_combined, axis = 0)[i], color=color_map(i), width=bar_width, label = label_costs[i])
    plt.xticks(X + i*bar_width/2, ("Service rate", ))
    plt.ylim(-1,0.8)

    plt.ylabel("Percentage [\%]")
    plt.title("\n".join(wrap('Temporal Distribution: ' + key[0] + "\n" + 'Spatial Distribution: ' +  key[1] + "\n" + 'Clusters: ' + str(key[2]), 35)))
    
    column = column + 1

    if column == 4:
        row = row + 1
        column = 0

plt.legend( loc="lower center", bbox_to_anchor=(0.25, -0.25), fancybox=True, shadow=False, ncol=3)
Out[8]:
<matplotlib.legend.Legend at 0x7fdddb140c40>

Takeaway:

RA:
  1. RA always offers minute improvements over the myopic scenario when demand is spread through out the map and not clustered in pockets of the city.
  2. As such there seems to be a relationship between the temporal structure of demand and performance, as when the demand is uniformly distributed in time, the impact of increasing spatial clusters on rewards adjustment diminishes. One important factor to note could be that with gaussian time distribution, most of the orders are placed close to each other.And as we've observed with the realistic case, a sharp increase in demand results in diminished performance of the anticipatory technique. This added with the fact that the demand is organized in specific regions that may be farther of depot locations results in rewards adjustment pushing vehicles to routes with limited possibility of future pickups. This can possibly be avoided if demand values are considered in rewards adjustment.
PA:
  1. As such PA, does not offer valuable improvement to most demand instances with the only exception being the the no spatial clustered scenarios with uniform time. This indicates that PA may offer benefit in scenarios where no inherent patterns in demand exist. It is safe to assume however, that real world instances could possibly have structure both spatially and temporally, with demand peaking at specific instances in the day resulting in limited capabilities of PA.

Performance Comparison Across Data set type

In [9]:
data_path = "/home/stavya/Desktop/deliver_fastest/Data_Generation/data/amsterdam"
base_path = "/home/stavya/Desktop/deliver_fastest/output/amsterdam"
color_map = colors.ListedColormap(['#fde725','#21918c','#3b528b','#440154'])

plt.rcParams.update({'font.size': 18})
time_first= 9 *3600
max_hour = 12*3600
finishing_time = 15
time_last=max_hour+finishing_time*60
steps = 100
used_vehicles = 10
considered_depots = 5

for num, key in enumerate(result_logger_dict.keys()):
     
    delivery_time_combined, delay_combined, TimeOnVehicle_combined, WaitingToPickUp_combined, delivered_combined, overall_cost_combined, mean_parcels_combined, driven_distance_combined, service_rate_combined = [],[],[],[],[],[],[],[],[]
        
    dif_overall_combined, dif_delivery_combined, dif_delay_combined, dif_veh_combined, dif_wait_combined, dif_service_combined, dif_dist_combined, dif_parcels_combined, dif_delivery_perorder_combined = [],[],[],[],[],[],[],[],[]  
        

    
    for i in range(n_datasets):
        folder_costs = []
        label_costs = []

        # Obtaining input foldersa
        for j,item in enumerate(output_folders[num][i].iterrows()):
            _, item = item
            folder_costs.append(item[0])
            label_costs.append(data_columns[num][i].iloc[j][0])
        
    
# Computing metrics
        demand, demand_time = load_demand(data_path, input_folders[num][i][0])
        
        delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores = load_graph_kpis(folder_costs, demand_time)
        
        dif_overall, dif_delivery, dif_delay, dif_veh, dif_wait, dif_service, dif_dist, dif_parcels, dif_delivery_perorder = load_graph_index(delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores)
        
         #Combining metrics
        delivery_time_combined.append(delivery_time_stores)
        delay_combined.append(delay_stores) 
        TimeOnVehicle_combined.append(TimeOnVehicle_stores)
        WaitingToPickUp_combined.append(WaitingToPickUp_stores) 
        delivered_combined.append(delivered) 
        overall_cost_combined.append(overall_cost)
        mean_parcels_combined.append(mean_parcels_stores)
        driven_distance_combined.append(driven_distance_stores)
        service_rate_combined.append(service_rate_stores)
        
        dif_overall_combined.append(dif_overall)
        dif_delivery_combined.append(dif_delivery)
        dif_delay_combined.append(dif_delay)
        dif_veh_combined.append(dif_veh)
        dif_wait_combined.append(dif_wait)
        dif_service_combined.append(dif_service)
        dif_dist_combined.append(dif_dist)
        dif_parcels_combined.append(dif_parcels)
    

    # Computing box plot metrics
    service_rate_box = [list(i) for i in zip(*service_rate_combined)]
    delivery_time_box = [list(i) for i in zip(*delivery_time_combined)]
    delay_box =  [list(i) for i in zip(*delay_combined)]
    TimeOnVehicle_box = [list(i) for i in zip(*TimeOnVehicle_combined)]
    WaitingToPickUp_box = [list(i) for i in zip(*WaitingToPickUp_combined)]
    delivered_box = [list(i) for i in zip(*delivered_combined)]
    overall_cost_box = [list(i) for i in zip(*overall_cost_combined)]
    mean_parcels_box = [list(i) for i in zip(*mean_parcels_combined)]
    driven_distance_box = [list(i) for i in zip(*driven_distance_combined)]
    
    dif_overall_box = [list(i) for i in zip(*dif_overall_combined)]
    dif_delivery_box = [list(i) for i in zip(*dif_delivery_combined)]
    dif_delay_box = [list(i) for i in zip(*dif_delay_combined)]
    dif_veh_box = [list(i) for i in zip(*dif_veh_combined)]
    dif_wait_box = [list(i) for i in zip(*dif_wait_combined)]
    dif_service_box = [list(i) for i in zip(*dif_service_combined)]
    dif_dist_box = [list(i) for i in zip(*dif_dist_combined)]
    dif_parcels_box = [list(i) for i in zip(*dif_parcels_combined)]
    
        
    # Plotting graphs
    printmd("<h3 style='color:grey;text-align:center'>" + 'Temporal Distribution: ' + key[0] + 
            ' &nbsp &nbsp &nbsp &nbsp &nbsp  Spatial Distribution: ' +  key[1] +  "</h3>")
    if key[2] != 0:
        printmd("<h4 style='color:grey;text-align:center''>" + 'Clusters: ' + str(key[2]) + "</h4>")

    bar_box_computer(folder_costs, label_costs, 'Average', delivery_time_box, delay_box, TimeOnVehicle_box, WaitingToPickUp_box, delivered_box, overall_cost_box, mean_parcels_box, driven_distance_box, service_rate_box, dif_overall_box, dif_delivery_box, dif_delay_box, dif_veh_box, dif_wait_box, dif_service_box, dif_dist_box, dif_parcels_box, color_map)

Temporal Distribution: gaussian           Spatial Distribution: gaussian

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

Results Findings:

To discuss: One must note, that these results are executed on a highly busy demand distribution system. As such the VGA framework is already running at maximum possible performance and hence, even minor improvement offered by anticipatory techniques add to the systems capabilities. The rate of improvement will further increase for systems that are not already running at maximum limits of computation. We shall run simulations results on less stressed scenario and highlight performance improvement to showcase those results

  1. Temporal Distribution: Gaussian , Spatial Distribution: gaussian: When both the time and space in the demand data are gaussian distributed, the feasible distance depot based rewards adjustment offers an improvement over the myopic case. THe number of orders served are greater without any substantial addition in delivery times. As such the vehicles also deliver this in lesser overall travelled distance.

  2. When the spatial data is clustered in 3,5 or 7 clusters, both the rewards adjustment and penalisation adjustment perform worse than the myopic scenario.

  3. When the spatial distribution is uniform, both RA and PA improve the system performance in terms of service rate, with RA offering a greater improvement

  4. With uniform clustered data and gaussian time, both RA and PA perform poorer than the myopic case. The only exception to this being the 7 clustered case, but this improvement is because of greater performance in one of the five simulations

  5. With gaussian space and uniform time, both RA and PA offer improvement over the myopic scenario

  6. With gaussian clustered space and uniform time, RA continues to perform better than the myopic case while PA doesnt. This improvement diminishes with increase in the number of clusters

  7. In the case where the data is uniformly distributed in time and space, both RA and PA perform better, with PA offering a greater improvement in service rate

  8. This improvement of PA quickly diminishes as reduces when the data is clustered spatially, while RA maintains a 0.2% improvement throughout

Service Rate Comparison Across Each Simulation Instance

In [17]:
plt.rcParams.update({'font.size': 16})
time_first= 9 *3600
max_hour = 12*3600
finishing_time = 15
time_last=max_hour+finishing_time*60
steps = 100
used_vehicles = 10
considered_depots = 5
gs = gridspec.GridSpec(16, 5, width_ratios=[1, 1, 1, 1, 1]) 
gs.update(wspace = 0.5, hspace = 0.5)

color_map = colors.ListedColormap(['#fde725','#21918c','#3b528b','#440154'])
data_path = "/home/stavya/Desktop/deliver_fastest/Data_Generation/data/amsterdam"
base_path = "/home/stavya/Desktop/deliver_fastest/output/amsterdam"

plt.subplots(figsize=(25,180))

row = 0
column = 0
for num, key in enumerate(result_logger_dict):
         


    for i in range(n_datasets):
        folder_costs = []
        label_costs = []

        # Obtaining input foldersa
        for j,item in enumerate(output_folders[num][i].iterrows()):
            _, item = item
            folder_costs.append(item[0])
            label_costs.append(data_columns[num][i].iloc[j][0])

        demand, demand_time = load_demand(data_path, input_folders[num][i][0])

        delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores = load_graph_kpis(folder_costs, demand_time)

        dif_overall, dif_delivery, dif_delay, dif_veh, dif_wait, dif_service, dif_dist, dif_parcels, dif_delivery_perorder = load_graph_index(delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores)
        
        X = np.arange(1)
        plt.subplot(gs[row,column])
        for i in range(len(folder_costs)):
            plt.bar(X + i*bar_width, dif_service[i], color=color_map(i), width=bar_width, label = label_costs[i])
        plt.xticks(X + i*bar_width/2, ("Service rate", ))
    #     plt.ylim(min(dif_service_combined)-0.1,max(dif_service_combined)+0.2)
        plt.ylabel("Percentage [\%]")

        if(column == 2):
            plt.title(label='Temporal Distribution: ' + key[0] + "\n" + 'Spatial Distribution: ' +  key[1] + "\n" + 'Clusters: ' + str(key[2]))

        column = column + 1

        if column == 5:
            row = row + 1
            column = 0

plt.legend( loc="lower center", bbox_to_anchor=(0.25, -0.5), fancybox=True, shadow=False, ncol=3)
Out[17]:
<matplotlib.legend.Legend at 0x7fddcf666340>

Performance Comparison Across Each Simulation Instance

In [18]:
data_path = "/home/stavya/Desktop/deliver_fastest/Data_Generation/data/amsterdam"
base_path = "/home/stavya/Desktop/deliver_fastest/output/amsterdam"
color_map = colors.ListedColormap(['#fde725','#21918c','#3b528b','#440154'])

plt.rcParams.update({'font.size': 18})
time_first= 9 *3600
max_hour = 12*3600
finishing_time = 15
time_last=max_hour+finishing_time*60
steps = 100
used_vehicles = 10
considered_depots = 5

for num, key in enumerate(result_logger_dict.keys()):
     
    delivery_time_combined, delay_combined, TimeOnVehicle_combined, WaitingToPickUp_combined, delivered_combined, overall_cost_combined, mean_parcels_combined, driven_distance_combined, service_rate_combined = [],[],[],[],[],[],[],[],[]
        
    dif_overall_combined, dif_delivery_combined, dif_delay_combined, dif_veh_combined, dif_wait_combined, dif_service_combined, dif_dist_combined, dif_parcels_combined, dif_delivery_perorder_combined = [],[],[],[],[],[],[],[],[]  
        

    
    for i in range(n_datasets):
        folder_costs = []
        label_costs = []

        # Obtaining input foldersa
        for j,item in enumerate(output_folders[num][i].iterrows()):
            _, item = item
            folder_costs.append(item[0])
            label_costs.append(data_columns[num][i].iloc[j][0])
        
    
# Computing metrics
        demand, demand_time = load_demand(data_path, input_folders[num][i][0])
        
        delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores = load_graph_kpis(folder_costs, demand_time)
        
        dif_overall, dif_delivery, dif_delay, dif_veh, dif_wait, dif_service, dif_dist, dif_parcels, dif_delivery_perorder = load_graph_index(delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores)
        

        # Plotting graphs
        printmd("<h3 style='color:grey;text-align:center'>" + 'Temporal Distribution: ' + key[0] + 
                ' &nbsp &nbsp &nbsp &nbsp &nbsp  Spatial Distribution: ' +  key[1] +  "</h3>")
        if key[2] != 0:
            printmd("<h4 style='color:grey;text-align:center''>" + 'Clusters: ' + str(key[2]) + "</h4>")
        
        
        printmd("<h4 style='color:grey;text-align:center''> Simulation "+str(i+1)+ "</h4>")
        bar_computer(folder_costs, label_costs, i+1, delivery_time_stores, delay_stores, TimeOnVehicle_stores, WaitingToPickUp_stores, delivered, overall_cost, mean_parcels_stores, driven_distance_stores, service_rate_stores, dif_overall, dif_delivery, dif_delay, dif_veh, dif_wait, dif_service, dif_dist, dif_parcels, dif_delivery_perorder, color_map)    

Temporal Distribution: gaussian           Spatial Distribution: gaussian

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: gaussian           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: gaussian           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: uniform           Spatial Distribution: gaussian clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 3</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 5</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 1</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 2</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 3</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 4</h4>

Temporal Distribution: uniform           Spatial Distribution: uniform clustered

<h4 style='color:grey;text-align:center''>Clusters: 7</h4>

<h4 style='color:grey;text-align:center''> Simulation 5</h4>